#include <iostream>
#include <string>
#include "46customTime.hpp"

CustomTime::CustomTime()
{
    this->hours = minutes = 0;
}

CustomTime::CustomTime(int hour, int min)
{
    this->hours = hour;
    this->minutes = min;
}

CustomTime::~CustomTime()
{
}

void CustomTime::addMin(int m)
{
    this->minutes += m;
    this->hours += minutes / 60;
    this->minutes %= 60;
}

void CustomTime::addHour(int hour)
{
    this->hours += hour;
}

void CustomTime::resetCustomTime(int hours, int minutes)
{
    this->hours = hours;
    this->minutes = minutes;
}

// CustomTime CustomTime::sumCustomTime(const CustomTime &time)
// {

// }
// 将上面的sum... 换成 operator+运算符重载
CustomTime CustomTime::operator+(const CustomTime &time) const
{
    CustomTime sum;
    sum.minutes = minutes + time.minutes;
    sum.hours = hours + time.hours + sum.minutes / 60;
    sum.minutes %= 60;
    return sum;
}
CustomTime CustomTime::operator*(const CustomTime &time) const
{
    CustomTime sum;
    sum.minutes = minutes * time.minutes;
    sum.hours = hours * time.hours * sum.minutes / 60;
    sum.minutes %= 60;
    return sum;
}

void CustomTime::show() const
{
    std::cout << hours << " hours, " << minutes << " minutes";
}
